package com.cet.designapplication.controller;

import com.cet.designapplication.composite.ProductComposite;
import com.cet.designapplication.pojo.ProductItem;
import com.cet.designapplication.service.ProductItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author NSOC
 */
@RestController
@RequestMapping("/product")
public class ProductItemController {

    @Autowired
    private ProductItemService productItemService;

    @PostMapping("/fetchAllItems")
    public ProductComposite fetchAllItems() {
        return productItemService.fetchAllItems();
    }

    @PostMapping("/addItem")
    public ProductComposite addItem(@RequestBody ProductItem productItem) {
        return productItemService.addItem(productItem);
    }

    @PostMapping("/delItem")
    public ProductComposite delItem(@RequestBody ProductItem productItem) {
        return productItemService.delItem(productItem);
    }
}
